library ReportCommand initializer init requires LegacySystem

	private function ReportCommand takes nothing returns nothing
		local integer i = 1
		local player p = GetTriggerPlayer()
		local integer id = GetConvertedPlayerId(p)
		call DisplayTimedTextToPlayer( p, 0, 0, 20.0, " " ) 
		call DisplayTimedTextToPlayer( p, 0, 0, 20.0, "|cfff3ad00Combat Report - 3rd Platoon, Echo Company|r" ) 
		call DisplayTimedTextToPlayer( p, 0, 0, 20.0, "Squad Rating: " + I2S(R2I(udg_SquadXP)) )
		call DisplayTimedTextToPlayer( p, 0, 0, 20.0, "Experience Gained: " + I2S(R2I(udg_Experience[id]-udg_InitialExperience[id])) )
		loop
			exitwhen i>udg_InitialPlayers
			if GetPlayerController(ConvertedPlayer(udg_Sorted[i]))==MAP_CONTROL_USER then
				if GetWidgetLife(udg_Hero[udg_Sorted[i]])>0.405 then
					call DisplayTimedTextToPlayer( p, 0, 0, 20.0, "|cff1e90ff" + GetUnitName(udg_Hero[udg_Sorted[i]]) + "|r " + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + " - " + I2S(GetPlayerScore(ConvertedPlayer(udg_Sorted[i]), PLAYER_SCORE_UNITS_KILLED)) + " kills / " + I2S(udg_PlayerHitsTaken[udg_Sorted[i]]) + " hits" )
				elseif udg_HeroSelected[udg_Sorted[i]] then
					call DisplayTimedTextToPlayer( p, 0, 0, 20.0, "|cffff0000KIA|r " + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + " - " + I2S(GetPlayerScore(ConvertedPlayer(udg_Sorted[i]), PLAYER_SCORE_UNITS_KILLED)) + " kills / " + I2S(udg_PlayerHitsTaken[udg_Sorted[i]]) + " hits"  )
				endif
			endif
			set i=i+1
		endloop
		call DisplayTimedTextToPlayer( p, 0.0, 0.0, 20.0, " " )
		call DisplayTimedTextToPlayer( p, 0.0, 0.0, 20.0, " " )
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		local integer i = 0
		set t = CreateTrigger()

		loop
			exitwhen i > 11
			call TriggerRegisterPlayerChatEvent(t, Player(i), "-report", true)
			set i = i + 1
		endloop

		call TriggerAddAction(t,function ReportCommand)
	endfunction
endlibrary